#pragma once
#include "types.h"
#include <cstring>

namespace Trade {

struct Position
{
  dir_t d = 0;
  int vol = 0;
  price_t avg_hpx = 0;
  price_t max_hop_win = 0;
  price_t hp_max_win = 0;     // price of max-win
  price_t max_hop_lost = 0;   // max-lost
  price_t max_lost_hp = 0;    // price of max-lost
  price_t float_hop_rvn = 0;  // float revnue in hop
  price_t float_revenue = 0;  // float revnue in $ = float_hop_rvn * vol - commision

  void print(const price_t hpx, const int64_t idx) const noexcept;
  void update_float_revenue(const price_t hpx) noexcept;
  void reset() noexcept { memset((void*)(this), 0, sizeof(Position)); }
  bool reached_max_win_loss(const price_t hpx) noexcept;
  bool force_stop_win(const price_t hpx) noexcept;
  bool force_stop_loss(const price_t hpx) noexcept;
};

} // namespace Trade